package com.test.exception_catch.global_exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public @ResponseBody String handleException(Exception e) {
        // 整个项目的异常都会到此
        return "全局异常捕获：" + e;
    }
}